|
|
|
|
|
|
|
project to include a particular header file more than once. Including a file in C is accomplished by using the command #include <filename> in the source file. This tells the compiler to scan the specified file during compilation. Let's say you have two header files, myfilel.h and myfile2.h, and a single source file mysourcefile. cpp. Next, assume that mysourcefile.cpp includes both of the header files, meaning that when it is compiled, the compiler will first scan the two headers, treating them as if they were part of the source file. Finally, assume that myfile2.h also includes myfilel.h. When the compiler tries to build mysoucefile.cpp, it will see the command #include "myfilel.h" and immediately scan that header file. Next, it will see the command #include "myfile2.h" and try to scan it. But while scanning this file, it will see another include of myfilel.h, causing the file to be effectively scanned twice. This can lead to problems, as the C/C++ language does not allow declaring certain elements more than once. |
|
|
|
|
|
|
|
|
The conditional compilation lines in this example prevent the cpuid.h file from being scanned more than once during a given compilation. The first time the file is scanned, the #ifndef cpuid_h line succeedsthe variable cpuid_h is not yet defined. The constant is then defined using the #define statement (though it is not given a value). The next time the file is scanned, the #ifndef cpuid_h line fails because the variable is defined, and all of the rest of the code in the header file is ignored. |
|
|
|
|
|
|
|
|
What does all of this mean to you as a Visual Basic programmer? Very little, because the concept of scanning a file more than once during compile time does not exist in VB. So all code of this type can be deleted. |
|
|
|
|
|
|
|
|
Discard Unneeded Function Declarations |
|
|
|
|
|
|
|
|
There may be function declarations that you simply don't need for your application. It doesn't make sense to port them unless you expect to need them in the future. There are also exported functions that are used only by the operating system, which you are unlikely to ever call from Visual Basic. These include: |
|
|
|
|
|
|
|
|
DllMain. The DLL initialization routine is called from the operating system, never directly. |
|
|
|
|
|
|
|
|
DllCanUnloadNow. This routine is called by the operating system to determine if an ActiveX server can be unloaded. |
|
|
|
|
|
|
|
|
DllGetClassObject. This routine is called by the operating system to create an ActiveX server object. |
|
|
|
|
|